kernelversion: add package for checking kernel versions#205
kernelversion: add package for checking kernel versions#205
Conversation
36b7be3 to
559b0dc
Compare
This implementation comes from github.com/cyphar/filepath-securejoin's internal/kernelversion package. Signed-off-by: Aleksa Sarai <[email protected]>
559b0dc to
9d4b40e
Compare
kolyshkin
left a comment
There was a problem hiding this comment.
Guess you have to make it buildable on !linux (if only to return an error) as some users have code for multiple platforms
| @@ -0,0 +1,13 @@ | |||
| // SPDX-License-Identifier: BSD-3-Clause | |||
| //go:build linux && go1.20 | |||
There was a problem hiding this comment.
Wonder why package doc requires go1.20 :)
| // same as GreaterEqualThan(KernelVersion{4, 0, 0, ..., 0, 0}), and that if the | ||
| // host kernel version is "4" then GreaterEqualThan(KernelVersion{4, 1}) will | ||
| // return false (because the host version will be treated as "4.0"). | ||
| func GreaterEqualThan(wantKver KernelVersion) (bool, error) { |
There was a problem hiding this comment.
Proper English would be something like "greater than or equal".
Or, we can use another name, say AtLeast. It will look like
if kernelversion.AtLeast(kernelversion.KernelVersion{4,2})which is still too much occurrences of "kernel" and "version", but otherwise ok.
Or, we can use a variadic function to simplify callers. Something like:
func AtLeast(want ...uint64)So the call can look simpler:
if kernelversion.AtLeast(2, 6, 19) {
...Or does it incur greater runtime overhead?
There was a problem hiding this comment.
Proper English would be something like "greater than or equal".
Or, we can use another name, say
AtLeast. It will look likeif kernelversion.AtLeast(kernelversion.KernelVersion{4,2})which is still too much occurrences of "kernel" and "version", but otherwise ok.
Or, we can use a variadic function to simplify callers. Something like:
func AtLeast(want ...uint64)So the call can look simpler:
if kernelversion.AtLeast(2, 6, 19) { ...Or does it incur greater runtime overhead?
|
@cyphar PTAL |
This implementation comes from github.com/cyphar/filepath-securejoin's
internal/kernelversion package.
Closes #204
Signed-off-by: Aleksa Sarai [email protected]